package cn.xuqiudong.rpc.test.provider;

import cn.xuqiudong.rpc.common.model.XqdUrl;
import cn.xuqiudong.rpc.test.service.DemoService;
import cn.xuqiudong.rpc.test.service.DemoServiceImpl;
import cn.xuqiudong.rpc.extension.XqdExtensionFactory;
import cn.xuqiudong.rpc.registry.Registry;
import cn.xuqiudong.rpc.registry.RegistryFactory;
import cn.xuqiudong.rpc.protocol.netty.XqdNettyServer;

import java.net.InetAddress;
import java.util.HashMap;
import java.util.Map;

/**
 * 描述:
 * @author Vic.xu
 * @date 2022-02-23 11:46
 */
public class ProviderMain {

    public  static final Map<String, DemoService> map= new HashMap<>();

    static String address = "localhost:2181";

    public static Registry registry = XqdExtensionFactory.defaultExtendFactory().getAdaptiveXqdExtension(RegistryFactory.class).getRegistry(address);

    public static void main(String[] args) throws Exception {
        int port = 6688;
        System.out.println(123);
        DemoService service = new DemoServiceImpl();
        String name = DemoService.class.getName();
        map.put(name, service);
        String hostAddress = InetAddress.getLocalHost().getHostAddress();
        XqdUrl xqdUrl = new XqdUrl(hostAddress, port, name);
        registry.register(xqdUrl);

        //启动一个netty server

        XqdNettyServer server = new XqdNettyServer(port);
        server.start();

        System.in.read();




    }
}
